import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout/Index.vue'

//1.引入页面
// const Home = () => import('@/views/Home.vue')
const Login  = () => import('@/views/login/Index.vue')
const PersonalIndex  = () => import('@/views/personal/Index.vue')
const PersonalMessage  = () => import('@/views/personal/Message.vue')
const AppIndex  = () => import('@/views/app/Index.vue')
const NotFound = () => import('@/views/404.vue')





//2.路由配置
const routesConfig = [
  // {
  //   path: '/',
  //   component: Home
  // }
  {
    path:'/',
    name:'Home',
    component:Layout,
    children:[
      //登录页
      {
        path:'login',
        name:'login',
        component:Login
      },
       //个人中心页
      {
        path:'personal',
        name:'Personal',
        component:PersonalIndex,
        children:[
        {
          path:'message',
          name:'PersonalMessage',
          component:PersonalMessage,
        }
        ]
      },
       //app内部页
      {
        path:'app',
        name:'APP',
        component:AppIndex
      },
       //404页
      {
        path:'404',
        name:'NotFound',
        component:NotFound
      },
    ]
  },
  {
    path:'/:pathMatch(.*)*',
    name:'404',
    redirect:'/404'
  }

]
//3.路由初始化
const router = createRouter({
  history: createWebHashHistory(),
  routes: routesConfig
})
//4.对外暴露出路由实例
export default router
